<template>
  <div>
    <h2>首页</h2>
    <p>欢迎来到本系统!</p>

    <router-link to="/home/news">新闻</router-link>
    <router-link to="/home/message">消息</router-link>
      <router-view />
  </div>
</template>

<script>

export default {
  data() {
    return {
      path:'/home/news'
    }
  },
  //记录当前路径
  activated() {
    this.$router.push(this.path);
  },
  //记录离开后当前路径
  beforeRouteLeave(to, from, next) {
    console.log(this.$route.path);
    this.path = this.$route.path;
    next()
  }
}
</script>
<style scoped>
a{
  text-decoration: none;
  margin: 10px;
  color: #666;
  font-size: 18px;
}
a:hover{
  text-decoration: underline;
  color: #ff6700;
}
li{
  list-style: none;
}
</style>
